//
//  WCInforDetailCell.m
//  WC
//
//  Created by wsj2015 on 16/1/25.
//  Copyright © 2016年 ShanghaiCize Trade And Business Co., Ltd. All rights reserved.
//

#import "WCInforDetailCell.h"
#import "NSString+Utilities.h"
#import "WCImageView +setImage.h"

@implementation WCInforDetailCell

- (void)awakeFromNib {
    // Initialization code
    
    self.bgVIew.layer.cornerRadius = 8;
    self.bgVIew.layer.masksToBounds = YES;
    self.bgVIew.layer.borderWidth =1;
    self.bgVIew.layer.borderColor =kBorderColor.CGColor;
    self.contentView.backgroundColor= kAppBg;
    self.selectionStyle = UITableViewCellSelectionStyleNone;
  
    
    
}
-(void)tapZoom:(UITapGestureRecognizer *)tap{
    
    UIImageView *imageView =(UIImageView*) tap.view;
    if (imageView.tag ==1) {
        [imageView zoomImageFromUrl:self.model.followupImage1 fromViewController:self.targetVC()];
    }
    if (imageView.tag ==2) {
        [imageView zoomImageFromUrl:self.model.followupImage2 fromViewController:self.targetVC()];
    }
    if (imageView.tag ==3) {
        [imageView zoomImageFromUrl:self.model.followupImage3 fromViewController:self.targetVC()];
    }
  
  
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(WCInforRecord *)model{
    _model = model;
   
    //移除所有手势
    for (UIImageView *imageView in self.picsView.subviews) {
        for (UIGestureRecognizer *g in imageView.gestureRecognizers) {
            [imageView removeGestureRecognizer:g];
        }
       
    }
    
    self.titleLabel.text = model.title;
    self.timeLabel.text = [NSString timeToString:[model.createTime longLongValue]];
    self.desLabel.text = model.content;
    if ([model.followupType integerValue] ==1) {
        if ([model.nurseId integerValue] ==[[WCDefaultManager shareMg] nurseId]) {
             self.nameLabel.text = [NSString stringWithFormat:@"由本人上传"];
        }
        self.nameLabel.text = [NSString stringWithFormat:@"由%@上传",model.nurseName];
    }else{
         self.nameLabel.text = [NSString stringWithFormat:@"由患者上传"];
    
    }
    
    self.leftImageView.hidden= NO;
    self.rightImageView.hidden= NO;
    self.centerImageView.hidden= NO;
    self.picsView.hidden = NO;
    if (model.followupImage1 &&![model.followupImage1 isEqualToString:@""]) {
        [self.leftImageView wsjSetImageWithUrl:model.followupImage1 withPlaceImageName:model.followupImage1];
    }else{
        [self.leftImageView setHidden:YES];
        
    }
    if (model.followupImage2 &&![model.followupImage2 isEqualToString:@""]) {
        [self.centerImageView wsjSetImageWithUrl:model.followupImage2 withPlaceImageName:model.followupImage2];
    }else{
        [self.centerImageView setHidden:YES];
    
    }
    if (model.followupImage3 &&![model.followupImage3 isEqualToString:@""]) {
        [self.rightImageView wsjSetImageWithUrl:model.followupImage3 withPlaceImageName:model.followupImage3];
    }else{
        [self.rightImageView setHidden:YES];
        
    }
    if (!model.followupImage1 && !model.followupImage2 && !model.followupImage3&&![model.followupImage1 isEqualToString:@""]&&![model.followupImage2 isEqualToString:@""]&&![model.followupImage3 isEqualToString:@""]) {
        [self.picsView setHidden:YES];
       self.picsViewHeight.constant =0;
    }else{
         self.picsViewHeight.constant =94;
    
    }
    
    //添加手势
    for (UIImageView *imageView in self.picsView.subviews) {
        imageView.userInteractionEnabled = YES;
        UITapGestureRecognizer * tap =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapZoom:)];
        [imageView addGestureRecognizer:tap];
    }
    

}


@end
